package day07;

import java.util.Random;
import java.util.Scanner;

public class apiday01 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入获取验证码的位数:");
        int j = sc.nextInt();
        VerificationCode(j);
    }

    private static void VerificationCode(int j) {
        String s = "";

        Random r = new Random();
        for (int i = 0; i < j; i++) {
            int num = r.nextInt(3);
            switch (num) {
                case 0:
                    char figure = (char) (r.nextInt(10) + 48);
                    s += figure;
                    break;
                case 1:
                    char upperCase = (char) (r.nextInt(26) + 65);
                    s += upperCase;
                    break;
                case 2:
                    char lowerCase = (char) (r.nextInt(26) + 97);
                    s += lowerCase;
                    break;
            }
        }
        System.out.println("生成的验证码是" + s);
    }
}
